Refactor AccentAnalyzer into ColorPaletteSampler #746
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR builds on #734 by removing the explicit 5 accent color properties on the
AccentAnalyzerand replaces it with anIList<ColorPaletteSelector>property.New XAML usage example:
<*.Resources> <helpers:ColorPaletteSampler x:Name="ColorPaletteSampler" Source="{x:Bind SampledImage}"> <helpers:AccentColorPaletteSelector x:Name="AccentPalette" MinColorCount="3" /> <helpers:ColorWeightPaletteSelector x:Name="WeightedColorPalette" MinColorCount="1" /> <helpers:BaseColorPaletteSelector x:Name="BasePalette" MinColorCount="1" /> </helpers:ColorPaletteSampler> </*.Resources> ... <!-- Any number of bindings you'd like with indexed SelectedColors! --> <SolidColorBrush Color="{x:Bind WeightedColorPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" />This allows a dynamic number of extracted color properties through combinations of color palette selectors, and even more by implementing your own custom
ColorPaletteSelector!Similar behavior was previously possible by making a derived class from the
AccentAnalyzerand overriding theSelectAccentColorsmethod. I believe this is a cleaner solution though, moving even dynamic numbers of extracted colors into pure XAML.Example in use:
